<template>
  <div class="explore">
    <div class="carousel-container">
      <div class="carousel" @mouseenter="pauseAutoPlay" @mouseleave="resumeAutoPlay">
        <div 
          class="carousel-item" 
          v-for="(car, index) in featuredCars" 
          :key="car.id"
          :class="{ active: currentIndex === index }"
        >
          <img :src="car.image" :alt="car.name">
          <div class="car-info">
            <h3>{{ car.name }}</h3>
            <p>{{ car.price }}</p>
            
          </div>
        </div>
        <button class="carousel-control prev" @click="prevSlide">‹</button>
        <button class="carousel-control next" @click="nextSlide">›</button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, onBeforeUnmount } from 'vue';

const featuredCars = ref([
  { id: 1, name: '极溯智擎', price: '尊享智慧人生', image: 'src/images/demo2.jpg'},
  { id: 2, name: '星级服务', price: '给予您难忘的体验', image: 'src/images/demo3.jpg' },
  { id: 3, name: '甄选品质', price: '保证您的购车体验', image: 'src/images/demo4.jpg' },
  { id: 4, name: '一手资讯', price: '掌握最新动态', image: 'src/images/demo1.jpg' },
  { id: 5, name: '携手合作', price: '与我们合作，分享您的经验', image: 'src/images/demo.jpg' },
]);
const currentIndex = ref(0);
const autoPlayInterval = ref(null);
const selectedCar = ref(null);
const configOptions = ref([]);
const selectedOptions = ref({});


const nextSlide = () => {
  currentIndex.value = (currentIndex.value + 1) % featuredCars.value.length;
};

const prevSlide = () => {
  currentIndex.value = (currentIndex.value - 1 + featuredCars.value.length) % featuredCars.value.length;
};

const startAutoPlay = () => {
  autoPlayInterval.value = setInterval(nextSlide, 5000);
};

const pauseAutoPlay = () => {
  clearInterval(autoPlayInterval.value);
};

const resumeAutoPlay = () => {
  startAutoPlay();
};

onMounted(() => {
  startAutoPlay();
});

onBeforeUnmount(() => {
  clearInterval(autoPlayInterval.value);
});
</script>

<style scoped>
html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  overflow: hidden;
}

.header {
  height: 120px;
  position: fixed;
  width: 100%;
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  padding: 0 5%;
  min-width: 320px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .header {
    grid-template-columns: 100px 1fr;
    grid-gap: 10px;
    padding: 0 2%;
  }
  .header-nav {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .header {
    grid-template-columns: 1fr;
    padding: 0 2%;
  }
}

.explore-container {
  max-width: 100vw;
  margin: 0;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.section-title {
  font-size: 2rem;
  margin-bottom: 3px;
  text-align: center;
  color: #c0c0c0;
  font-weight: 250;
  letter-spacing: 0.05em;
}

.tech-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2.5rem;
}

.tech-card {
  position: relative;
  background: rgba(20, 20, 20, 0.8);
  border-radius: 4px;
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.tech-card:hover {
  background: rgba(30, 30, 30, 0.9);
  transform: translateY(-3px);
}

.card-content h3 {
  color: #ffffff;
  margin-bottom: 1rem;
  font-weight: 300;
  font-size: 1.5rem;
}

.card-content p {
  color: #d0d0d0;
  line-height: 1.8;
  font-weight: 300;
}
.explore {
  max-width: 1200px;
  margin: 0 auto;
  margin-bottom: 2rem;
}

.carousel-container {
  width: 99.5vw;
  height: calc(100vh - 120px);
  margin-left: calc(-50vw + 50%);
  overflow: hidden;
  position: relative;
}

.carousel {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
}

.carousel-item {
  width: 100%;
  height: 100%;
  position: relative;
  opacity: 0;
  transition: opacity 0.5s ease;
  display: none;
}

.carousel-item.active {
  opacity: 1;
  display: block; 
}

.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.car-info {
  position: absolute;
  top: 20%;
  left: 10%;
  text-align: left;
  max-width: 35%;
  color: #ffffff;
  padding: 2rem;
  font-size: 2rem;
  line-height: 1.6;
  border-radius: 12px;
}

@media (max-width: 768px) {
  .car-info {
    top: 15%;
    left: 8%;
    max-width: 84%;
    font-size: 1.6rem;
    padding: 1.5rem;
  }
}

.carousel-control {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.3);
  border: none;
  color: white;
  font-size: 2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
}

.carousel-control:hover {
  background: rgba(255, 255, 255, 0.5);
}

.prev {
  left: 20px;
}

.next {
  right: 20px;
}

.configuration {
  margin-top: 3rem;
}

.section-subtitle {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: #333;
}

.config-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
}

.config-group h3 {
  margin-bottom: 1rem;
  color: #555;
}

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.option-item {
  border: 1px solid #ddd;
  padding: 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.option-item:hover {
  border-color: #000000;
}

.option-item.selected {
  border-color: #000000;
  background-color: #3f4040;
}

.option-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  margin-bottom: 0.5rem;
}

.price {
  color: #e74c3c;
  font-weight: bold;
}

.config-summary {
  margin-top: 2rem;
  padding: 1.5rem;
  background-color: #181818;
  border-radius: 8px;
}

.total-price {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 1rem 0;
}

.submit-btn {
  background-color: #0066cc;
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.submit-btn:hover {
  background-color: #0052a3;
}
</style>
